package cn.ld.module.infra.dal.mapper.file;

import cn.ld.framework.common.pojo.PageResult;
import cn.ld.framework.mybatis.core.mapper.BaseMapperX;
import cn.ld.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.ld.module.infra.controller.admin.file.vo.config.FileConfigPageInVO;
import cn.ld.module.infra.dal.entity.file.FileConfigEntity;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface FileConfigMapper extends BaseMapperX<FileConfigEntity> {

    default PageResult<FileConfigEntity> selectPage(FileConfigPageInVO inVO) {
        return selectPage(inVO, new LambdaQueryWrapperX<FileConfigEntity>()
                .likeIfPresent(FileConfigEntity::getName, inVO.getName())
                .eqIfPresent(FileConfigEntity::getStorage, inVO.getStorage())
                .betweenIfPresent(FileConfigEntity::getCreateTime, inVO.getCreateTime())
                .orderByDesc(FileConfigEntity::getId));
    }

    default FileConfigEntity selectByMaster() {
        return selectOne(FileConfigEntity::getMaster, true);
    }

}
